from typing import List, Dict, Any, Optional, TypedDict, Literal

# 视频文件验证结果
class VideoFileValidationResult(TypedDict):
    is_valid: bool
    error: str

# 视频帧信息
class VideoFrame(TypedDict):
    frame_index: int
    timestamp: float
    image: Any  # OpenCV图像对象

# 视频帧元数据（不包含图像数据）
class VideoFrameMetadata(TypedDict):
    frame_id: int
    frame_index: int
    timestamp: float

# 视频信息
class VideoInfo(TypedDict):
    fps: float
    total_frames: int
    width: int
    height: int
    duration_seconds: float

# 音频段落结果
class AudioSegmentResult(TypedDict):
    segment_id: int
    start_time: float
    end_time: float
    text: str
    error: str

# 视频文本提取结果
class VideoTextExtractionResult(TypedDict):
    success: bool
    file_name: str
    file_path: str
    text: str
    error: str
    segments: List[AudioSegmentResult]
    frames: List[VideoFrameMetadata]
    video_info: VideoInfo

class VideoFramesExtractionResult(TypedDict):
    success: bool
    file_name: str
    file_path: str
    text: str
    error: str
    frames: List[VideoFrameMetadata]
    video_info: VideoInfo

# 批量处理结果
class BatchProcessingResult(TypedDict):
    success: bool
    directory: str
    total_files: int
    successful_extractions: int
    results: List[VideoTextExtractionResult]
    error: Optional[str]

# 支持的视频格式
SupportedVideoFormat = Literal['.mp4', '.avi', '.mov', '.mkv', '.flv', '.wmv']

# 音频提取结果
class AudioExtractionResult(TypedDict):
    audio_path: Optional[str]
    error: Optional[str]